package yjj.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import yjj.system.entity.Permission;
import yjj.system.mapper.PermissionMapper;
import yjj.system.service.PermissionService;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
    @Override
    public List<String> getPermissionByIds(List<String> permissionIds) {
        LambdaQueryWrapper<Permission> queryWrapper = new LambdaQueryWrapper<>();
       queryWrapper.in(Permission::getPermissionId, permissionIds);
        List<Permission> list = this.list(queryWrapper);
        if (!list.isEmpty()) {
            return list.stream().map(Permission::getUrl).collect(Collectors.toList());
        }
        return null;
    }
}
